home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3595 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.0 KB  |  37 lines

  1. Path: oxy.rust.net!usenet
  2. From: ebennett@rust.net
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Floating point overflow
  5. Date: Thu, 25 Jan 1996 04:01:16 GMT
  6. Organization: Rust Net - High Speed Internet in Detroit  810-642-2276
  7. Message-ID: <4e6ko7$ela@oxy.rust.net>
  8. References: <4dp9g6$spe@sphinx.Gsu.EDU>
  9. NNTP-Posting-Host: liv-18.rust.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. gs01jpc@panther.Gsu.EDU (J. Patrick Cline) wrote:
  13.  
  14. >Why would the following bit of code give me a floating point overflow 
  15. >when compiled as a Borland EasyWin target?
  16.  
  17. >#include <iostream.h>
  18.  
  19. >double someVar;
  20.  
  21. >void main() {
  22. >   cout << "Enter a float:";
  23. >   cin >> someVar;   // Floating point error occurrs after pressing Enter
  24. >                     // Works fine as a DOS app
  25. >}
  26.  
  27. Unlike DOS apps, Windows programs (an EasyWin program is actually a
  28. Windows program) do not zero out static (global) data during startup.
  29. someVar is starting out with garbage in it, and it is probably not
  30. recognizable as a valid number.
  31.  
  32. Counting on C to zero initialize data for you is a poor practice.
  33.  
  34. Earl Bennett
  35.  
  36.  
  37.